package org.wejde.muel;

/**
 * This class contains the members and methods related to
 * the muel input fields (fields).  The fields contain all
 * of the data and behavior metadata for an inputfield.
 *  
 * @author Eric Martin
 * @author Webb Pinner
 *
 */
public class fields {

	// JComponent Type enumeration.
	final static short INVALID = -1;
	final static short CHECKBOX = 0;
	final static short TEXTFIELD = 1;
	final static short COMBOBOX = 2;
		
	// TRUE/FALSE text statards
	final static String TRUE = "TRUE";
	final static String FALSE = "FALSE";
	
	// Field Members
	
	// Unique ID
	private int ID;
	
	// Field Label, how to label the field.
	private String label;
	
	// Field Value, value(s).  This object is an array to
	// account for JComboBox JComponents.  The first value
	// in the array will be displayed by default.
	private String [] value;
	
	// Field Hidden Value, value(s).  This object is an
	// array to account for JComboBox JComponents.  Each
	// hidden value directly correlates to the equivalent
	// element in the value array.
	private String [] hiddenValue;

	// Field Tooltip, this text is for what to display when
	// hovering over a field.
	private String tooltip;
	
	// Field Type, the JComponent type, should only be set
	// using the JComponent Type enumeration for the fields
	// class.
	private short type;
	
	// Clear Flag, defines whether or not the field should
	// be cleared.
	private boolean clearOnSubmit;
	
	// Use only hidden flag, defines whether to output the
	// hidden and value array values (false) or just the
	// value of the hidden array (true)
	private boolean useOnlyHidden;

	
	/**
	 * Constructor method.
	 */
	public fields(int ID) {
		this.setFieldID(ID);
		this.setFieldLabel("null");
		this.setFieldValue(new String[] {"null"});
		this.setFieldHiddenValue(new String[] {"null"});
		this.setFieldTooltip("null");
		this.setFieldType(fields.INVALID);
		this.setFieldClearOnSubmit(true);
		this.setFieldUseOnlyHidden(false);
	}

	/**
	 * Constructor method.
	 */
	public fields(int ID, String label, String [] value, String [] hiddenValue, String tooltip, short type, boolean clearOnSubmit, boolean useOnlyHidden) {
		this.setFieldID(ID);
		this.setFieldLabel(label);
		this.setFieldValue(value);
		this.setFieldHiddenValue(hiddenValue);
		this.setFieldTooltip(tooltip);
		this.setFieldType(type);
		this.setFieldClearOnSubmit(clearOnSubmit);
		this.setFieldUseOnlyHidden(useOnlyHidden);

	}

	/**
	 * Return the ID for the field
	 * 
	 * @return the ID
	 */
	public int getFieldID() {
		return ID;
	}

	/**
	 * Set the ID for the field
	 * 
	 * @param iD the iD to set
	 */
	public void setFieldID(int iD) {
		ID = iD;
	}

	/**
	 * Return the label for the field
	 * 
	 * @return the label
	 */
	public String getFieldLabel() {
		return label;
	}

	/**
	 * Set the label for the field
	 * 
	 * @param label the label to set
	 */
	public void setFieldLabel(String label) {
		this.label = label;
	}

	/**
	 * Return the value array for the field
	 * 
	 * @return the value
	 */
	public String [] getFieldValue() {
		return value;
	}

	/**
	 * Set the value array for the field
	 * 
	 * @param value the value to set
	 */
	public void setFieldValue(String [] value) {
		this.value = value;
	}

	/**
	 * Return the array of hidden values for the field.
	 * 
	 * @return the hiddenValue
	 */
	public String [] getFieldHiddenValue() {
		return hiddenValue;
	}

	/**
	 * Set the hidden value array for the field
	 * 
	 * @param hiddenValue the hiddenValue to set
	 */
	public void setFieldHiddenValue(String [] hiddenValue) {
		this.hiddenValue = hiddenValue;
	}

	/**
	 * Return the tooltip for the field.
	 * 
	 * @return the tooltip
	 */
	public String getFieldTooltip() {
		return tooltip;
	}

	/**
	 * Set the tooltip for the field.
	 * 
	 * @param tooltip the tooltip to set
	 */
	public void setFieldTooltip(String tooltip) {
		this.tooltip = tooltip;
	}

	/**
	 * Return the JComponent type for the field. 
	 * 
	 * @return the type
	 */
	public short getFieldType() {
		return type;
	}

	/**
	 * Set the JComponent type for the field
	 * 
	 * @param type the type to set
	 */
	public void setFieldType(short type) {
		this.type = type;
	}

	/**
	 * Return the clearOnSubmit boolean value for the
	 * field.
	 * 
	 * @return the clearOnSubmit
	 */
	public boolean isFieldClearOnSubmit() {
		return clearOnSubmit;
	}

	/**
	 * Set the clearOnSubmit flag for the field.
	 * 
	 * @param clearOnSubmit the clearOnSubmit to set
	 */
	public void setFieldClearOnSubmit(boolean clearOnSubmit) {
		this.clearOnSubmit = clearOnSubmit;
	}

	/**
	 * Return the clearOnSubmit boolean value for the
	 * field.
	 * 
	 * @return the clearOnSubmit
	 */
	public boolean isUseOnlyHidden() {
		return useOnlyHidden;
	}

	/**
	 * Set the clearOnSubmit flag for the field.
	 * 
	 * @param clearOnSubmit the clearOnSubmit to set
	 */
	public void setFieldUseOnlyHidden(boolean useOnlyHidden) {
		this.useOnlyHidden = useOnlyHidden;
	}

	
}
